package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.entity.Employee;
import com.sky.result.PageResult;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface EmployeeMapper {

    /**
     * 根据用户名查询员工
     * @param username
     * @return
     */
    @Select("select * from employee where username = #{username}")
    Employee getByUsername(String username);

    @Select("select * from employee where id = #{id}")
    Employee getById(long id);

    @Insert("INSERT INTO employee(name, username, password, phone, sex, id_number, status, create_user, update_user) " +
            "VALUES(#{name}, #{username}, #{password}, #{phone}, #{sex}, #{idNumber}, #{status}, #{createUser}, #{updateUser})")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    void insert(Employee employee);

    /**分页查询
     *
     * @param name
     * @return
     */
    Page<Employee> pageQuery(String name);

    @Update("update employee set status = #{status} where id = #{id}")
    void update(Integer status, long id);
}
